package com.bjfl.bean;

/**
 * Created by 86463 on 2017/12/18.
 */

public class GoodsLineMsg implements Comparable<GoodsLineMsg> {
    public static final String ADD_GOODS = "add";
    public static final String BUY_GOODS = "buy";
    private String layerNum;
    private String lineNum;
    private String layerAndLineNum;
    private String isAddAction;//加货or补货
    private String lineLength;

    public GoodsLineMsg() {
    }

    public String getLayerNum() {
        return layerNum;
    }

    public void setLayerNum(String layerNum) {
        this.layerNum = layerNum;
    }

    public String getLineNum() {
        return lineNum;
    }

    public void setLineNum(String lineNum) {
        this.lineNum = lineNum;
    }

    public String getLayerAndLineNum() {
        return layerAndLineNum;
    }

    public void setLayerAndLineNum(String layerAndLineNum) {
        this.layerAndLineNum = layerAndLineNum;
    }

    public String getIsAddAction() {
        return isAddAction;
    }

    public void setIsAddAction(String isAddAction) {
        this.isAddAction = isAddAction;
    }

    public String getLineLength() {
        return lineLength;
    }

    public void setLineLength(String lineLength) {
        this.lineLength = lineLength;
    }

    @Override
    public String toString() {
        return "GoodsLineMsg{" +
                "layerNum='" + layerNum + '\'' +
                ", lineNum='" + lineNum + '\'' +
                ", layerAndLineNum='" + layerAndLineNum + '\'' +
                ", isAddAction='" + isAddAction + '\'' +
                ", lineLength='" + lineLength + '\'' +
                '}';
    }

    @Override
    public int hashCode() {
        return layerAndLineNum.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if(this==obj) return true;    //这个在父类Object 里的hashCode就已经比较过  ，可以省去
        if(this.getClass()!=obj.getClass()) return false;
        GoodsLineMsg goodsLineMsg = (GoodsLineMsg) obj;
        return layerAndLineNum.equals(goodsLineMsg.getLayerAndLineNum());
    }

    @Override
    public int compareTo(GoodsLineMsg o) {
        int curentLineNum = Integer.parseInt(getLayerAndLineNum());
        int preLineNum = Integer.parseInt(o.getLayerAndLineNum());
        return curentLineNum - preLineNum == 0 ? 0 :
                (curentLineNum - preLineNum < 0 ? -1 : 1);
    }
}
